<?php
/* -----------------------------------------------------------------
 *                        Aveghe My Blog
 * -----------------------------------------------------------------
 * Aveghe My Blog: made your blog easy!
 * Copyright (C) 2008 Elia Contini
 * 
 * Aveghe My Blog is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * Aveghe My Blog is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

require_once('aveghe/views/helpers/MainMenu.php');

$meta    = $this->head('meta'   , 'admin', $this->preferences);
$style   = $this->head('style'  , 'admin', $this->preferences);
$favicon = $this->head('favicon', 'admin', $this->preferences);
$rss     = $this->head('rss'    , 'admin', $this->preferences);

$baseURL = BASE_URL;

$siteTitle = '<h1><a href="'.$baseURL.'/" title="">'.stripcslashes($this->preferences['site_title'])."</a></h1>\n";

$report = '';
if(count($this->report) > 0)
	{
		$report = "\n<div id=\"report\">\n\t".stripslashes($this->report[0])."</div>\n";
	}

$helloLogout = $this->helloLogout($this->userInfo['user_name'], $baseURL);
$menu = $this->mainMenu(Aveghe_View_Helper_MainMenu::DOCUMENTS, $baseURL);

$parentFolder = $this->parentFolder['document_parent_directory'];

$content = "<div id=\"view\">\n<ul id=\"iconView\">\n";

if($this->currentFolder > 0)
	$content .= "<li class=\"parent\"><a href=\"".$baseURL."/doc/show-folder/id/".$parentFolder."\" title=\"\">Cartella superiore</a></li>\n";

if(count($this->docs))
	{
		foreach($this->docs as $docs)
			{
				$fileName = stripslashes($docs['document_name']);
				$fileName = html_entity_decode($fileName, ENT_QUOTES, 'UTF-8');
				
				$fileNameLenght = strlen($fileName);
				
				if($fileNameLenght > 17)
					{
						$fileName = substr($fileName, 0, 17).'...';
					}
					
				//$filename = htmlentities($fileName, ENT_QUOTES, 'UTF-8');
				
				//echo $fileName; die;
				
				switch($docs['document_type'])
					{
						case '-': { 
									$content .= "<li class=\"file\"><a href=\"".$baseURL."/doc/edit/id/".$docs['document_id']."\" title=\"\">".$fileName."</a></li>\n";
									break;
								  }
						case 'd': {
									$content .= "<li class=\"directory\"><a href=\"".$baseURL."/doc/show-folder/id/".$docs['document_id']."\" title=\"\">".$fileName."</a></li>\n";
									break;
								  }
					}
			}
	}
	
$content .= "</ul>\n";
$content .= "</div>\n";

$content .= <<<MENU

	<div id="actions">
		<ul id="actionsList">
			<li><a href="$baseURL/doc/new-document" title="">Crea Post</a></li>
			<li><a href="$baseURL/doc/new-folder" title="">Crea Categoria</a></li>
		</ul>
	</div>

MENU;

include 'aveghe/themes/admin/'.$this->preferences['site_admin_theme'].'/template_admin.xhtml';
?>